package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;

/**
 * 分析：
 * 实现：
 * 经验：
 * 教训：
 * 分类：数学
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P1423 {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P1423.class.getResource("P1423.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		StringBuffer sb = new StringBuffer("");
		String line = stdin.readLine();
		int T = Integer.valueOf(line.trim());
		for (int i = 0; i < T; i ++) {
			line = stdin.readLine();
			int n = Integer.valueOf(line.trim());
			int d = 1+(int)(Math.log10(2*Math.PI*n)*0.5f + n*Math.log10(n) - n*Math.log10(Math.E));
			sb.append(d).append("\n");
		}
		System.out.println(sb);
	}
}